package com.ebao.po.blog;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.ebao.constants.UserType;

/**
 * @desc 相册
 * @author snow
 * @date 2012-7-10
 */
@Entity
@Table(name = "T_Album")
public class TAlbum implements Serializable {

	private static final long serialVersionUID = -721137118486636738L;
	
	private Long id;
	private UserType ownerType;		// 属主类型user/doctor
	private String ownerId;			// 属主Id
	private String albumName;		// 相册名称
	private String description;		// 相册说明、描述
	private String createDate;		// 相册创建日期
	private String coverUrl;		// 相册封面Url,默认为上传后相册里第一张图片的地址,可设置相册封面
	private List<TPhoto> photos = new ArrayList<TPhoto>();	// 相册内的图片
	private Set<TAlbumComment> albumComment = new HashSet<TAlbumComment>();	// 相册评论,在Action中转换为List
//	private Set<TAlbumAccess> albumAccess = new HashSet<TAlbumAccess>();	// 相册访问记录,在Action中转换为List

	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public UserType getOwnerType() {
		return ownerType;
	}

	public void setOwnerType(UserType ownerType) {
		this.ownerType = ownerType;
	}

	public String getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(String ownerId) {
		this.ownerId = ownerId;
	}

	public String getAlbumName() {
		return albumName;
	}

	public void setAlbumName(String albumName) {
		this.albumName = albumName;
	}

	@Column(length = 19)
	public String getCreateDate() {
		return createDate;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public String getCoverUrl() {
		return coverUrl;
	}

	public void setCoverUrl(String coverUrl) {
		this.coverUrl = coverUrl;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "album", targetEntity = TPhoto.class)
	public List<TPhoto> getPhotos() {
		return photos;
	}

	public void setPhotos(List<TPhoto> photos) {
		this.photos = photos;
	}
	
	@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "album", targetEntity = TAlbumComment.class)
	public Set<TAlbumComment> getAlbumComment() {
		return albumComment;
	}

	public void setAlbumComment(Set<TAlbumComment> albumComment) {
		this.albumComment = albumComment;
	}

}
